import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Query,
  Put,
} from '@nestjs/common';
import { SpecificationService } from './specification.service';

@Controller('specification')
export class SpecificationController {
  constructor(private readonly specificationService: SpecificationService) {}

  @Post()
  create(@Body() createData) {
    return this.specificationService.create(createData);
  }

  @Post('list')
  findAll(@Body() createData) {
    return this.specificationService.findAll({ ...createData });
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.specificationService.findOne({ id });
  }

  @Put()
  update(@Body() updateData) {
    return this.specificationService.update({
      where: { id: +updateData.id },
      data: updateData,
    });
  }

  @Delete()
  remove(@Query('id') id: number) {
    return this.specificationService.delete({ id });
  }
}
